//
//  UIImage+TYLayer.m
//  TYUIKit
//
//  Created by TuyaInc on 2018/11/27.
//

#import "UIImage+TYLayer.h"

@implementation UIImage (TYLayer)

+ (UIImage *)ty_imageWithLayer:(CALayer *)layer {
    UIGraphicsBeginImageContextWithOptions(layer.bounds.size, layer.opaque, 0);
    [layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}

+ (UIImage *)ty_imageWithView:(UIView *)view {
    return [self ty_imageWithLayer:view.layer];
}

@end
